$(function(){
	showCondition(true, 0, 0, 1,[]);//加载查询条件
	var dateFrom=paramTabPage[tabId].dateFrom;
	var dateTo=paramTabPage[tabId].dateTo;
	medInsTableData(dateFrom,dateTo);
})
function medInsTableData(dateFrom,dateTo){
	$('#medins_id').html('<table class="table display nowrap"  id="medinsTable_id"'
	 		   +'style="text-align: center;transition:all .2s;">'
	 			+'<thead>'
		 		+'<tr><td>主键</td><td>病案号</td>'
				 +'<td>基金支付(元)</td><td>自费费用(元)</td><td>个人自付一(元)</td><td>个人自付二(元)</td><td>医疗类别</td><td>红冲标志</td><td>入院日期</td>'
				 +'<td>出院日期</td><td>出院类型</td><td>医保类型</td><td>拒付总金额(元)</td><td>拒付原因</td><td>点击修改</td></thead>'
		 		+'<tbody id="table"></tbody>'
		 		+'</table>');
	$.post(contextPath+'/medinsComplete/medInsQuestionsQuery.dhc',{
		'dateFrom':dateFrom,
		'dateTo':dateTo
	},function(data){
		var columns=[
			{"data":"PARID"},
			{"data":"MR_NO"},
			{"data":"FUND_PAY"},
			{"data":"PRIVATE_PAY"},
			{"data":"PRIVATE_PAY1"},
			{"data":"PRIVATE_PAY2"},
			{"data":"MEDICAL_CATEGORY"},
			{"data":"RED_MARK"},
			{"data":"IN_DATE"},
			{"data":"OUT_DATE"},
			{"data":"OUT_TYPE"},
			{"data":"DIC_DESC"},
			{"data":"REFUSE_FEE"},
			{"data":"REFUSE_REASON"},
			{"data":"",render:function(obj,type,full){
                 return '<a href="javascript:editMedins(\''+full.PARID+'\',\''+full.MR_NO+'\',\''+full.OUT_DATE+'\',\''+full.IN_DATE+'\')"><i class=\"icon-pencil\"></i></a>';
			}}
		];
		var paramTableDatas={order:[[1,"asc"]],scrollX:true};
		$("#medinsTable_id").dataTableBasic(columns,data.data,paramTableDatas);
	})
}
function editMedins(parid,mrNo,outDate,inDate){
	outDate=outDate=="null"?"":outDate;
	inDate=inDate=="null"?"":inDate;
	$("#out_date").val(outDate);
	$("#in_date").val(inDate);
	$("#medins_mrNo").val(mrNo);
	$("#medins_old_id").val(parid);
	$("#edit_modal").modal('show');
}
$("#submit_btn").on('click', function() {
	var outDateNew = $("#out_date").val();
	var inDateNew = $("#in_date").val();
	var pmainindex = $("#medins_old_id").val();
	var mrNo = $("#medins_mrNo").val();
	if (outDateNew == '' || inDateNew == '') {
		drgUI.warning('不能为空，请重新输入！');
		return false;
	} else {
		$.post(contextPath + '/medinsComplete/updateMedinsQuery.dhc', {
			'id' : pmainindex,
			'outDate' : outDateNew,
			'inDate' : inDateNew,
			'mrNo' : mrNo
		}, function(result) {
			if(result=="0"){
				drgUI.success('匹配成功！');
			}else{
				drgUI.error('修改成功后未匹配成功！');
			}
			$('#edit_modal').modal('hide');
			medInsTableData(paramTabPage[tabId].dateFrom,paramTabPage[tabId].dateTo);
		});
	}
});
